package com.spark.common

import io.reactivex.Observable
import io.reactivex.disposables.CompositeDisposable

interface IView

interface IModel

interface IPresenter<in V : IView, out IM : IModel> {
    fun attachView(iView: V)
    fun detachView()
    fun getIModel(): IM
}

abstract class BaseView : IView

abstract class BaseModel<Data> : IModel {
    abstract fun datasFromServer(): Observable<MutableList<Data>>
    abstract fun datasFromLocal(): Observable<MutableList<Data>>
    abstract fun datasToLocal(datas: MutableList<Data>)
}

abstract class BasePresenter<V : IView, IM : IModel> : IPresenter<V, IM> {
    open lateinit var imodel: IM
    open lateinit var iview: V
    open var dispos: CompositeDisposable = CompositeDisposable()

    override fun attachView(iView: V) {
        imodel = getIModel()
        this.iview = iview
    }

    override fun detachView() {
        dispos.clear()
    }
}